﻿using UnityEngine;

public class BattleQualityManager : MonoBehaviour
{
    public Light sunLight;
    public GameObject WaterHighRes;
    public GameObject WaterLowRes;

    public GameObject Clouds;


    private void Start()
    {
        onQualityChange();
        Mainloop.Instance.onQualityChange += onQualityChange;
    }

    private void OnDestroy()
    {
        Mainloop.Instance.onQualityChange -= onQualityChange;
    }

    void onQualityChange()
    {
        
        int currentQuality = Mainloop.Instance.QualityLevel;

        if (currentQuality >= 3)
        {
            sunLight.enabled = true;
        }
        else
        {
            sunLight.enabled = false;
        }
        
        if(currentQuality >= 3)
        {
            if (Clouds != null)
                Clouds.SetActive(true);
        }
        else
        {
            if (Clouds != null)
                Clouds.SetActive(false);
        }

        if(currentQuality >= 2)
        {
            if (WaterHighRes != null) WaterHighRes.SetActive(true);
            if (WaterLowRes != null) WaterLowRes.SetActive(false);
        } 
        else
        {
            if (WaterHighRes != null) WaterHighRes.SetActive(false);
            if (WaterLowRes != null) WaterLowRes.SetActive(true);
        }
        
    }
}
